package com.alex.springboot.controller;

import com.alex.springboot.dao.RoleRepository;
import com.alex.springboot.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleRepository roleRepository;

    @PostMapping("/save")
    public Role save(@ModelAttribute Role role) {
        roleRepository.save(role);
//        // 删除
//        roleRepository.deleteById(id);
//        // 查询
//        roleRepository.getOne(id);
//        roleRepository.findAll();
        return role;
    }

    @PutMapping("/update")
    public Role update(Role role) {
        roleRepository.save(role);
        return role;
    }

}
